
package com.platform.modules.mall.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.utils.Query;
import com.platform.modules.mall.dao.MallGoodsInstallmentsDao;
import com.platform.modules.mall.entity.MallGoodsInstallmentsEntity;
import com.platform.modules.mall.service.MallGoodsInstallmentsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 商品分期对应表Service实现类
 *
 * @author
 * @date 2020-10-30 15:58:36
 */
@Service("mallGoodsInstallmentsService")
public class MallGoodsInstallmentsServiceImpl extends ServiceImpl<MallGoodsInstallmentsDao, MallGoodsInstallmentsEntity> implements MallGoodsInstallmentsService {

    @Override
    public List<MallGoodsInstallmentsEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.id");
        params.put("asc", false);
        Page<MallGoodsInstallmentsEntity> page = new Query<MallGoodsInstallmentsEntity>(params).getPage();
        return page.setRecords(baseMapper.selectMallGoodsInstallmentsPage(page, params));
    }

    @Override
    public boolean add(MallGoodsInstallmentsEntity mallGoodsInstallments) {
        return this.save(mallGoodsInstallments);
    }

    @Override
    public boolean update(MallGoodsInstallmentsEntity mallGoodsInstallments) {
        return this.updateById(mallGoodsInstallments);
    }

    @Override
    public boolean delete(String id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(String[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }
    @Override
    public boolean deleteByGoodsId(String id) {
        return baseMapper.deleteByGoodsId(id);
    }
}
